package containerlogistik.implementation;

import containerlogistik.interfaces.Name;
import java.util.Objects;
/**
 * 
 * @param Implementation von Name
 *
 */
public class NameImpl implements Name {
    
    final String name;
    
    private NameImpl(String name) {
        this.name = name;
    }
    
    static Name valueOf(String name) {
        return new NameImpl(name);
    }

    @Override
    public String nameString() {
        return this.name;
    }

    @Override
    public int compareTo(Name o) {
        return this.nameString().compareTo(o.nameString());
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (!(obj instanceof Name)) return false;
        return this.compareTo((Name)obj) == 0;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 47 * hash + Objects.hashCode(this.nameString());
        return hash;
    }

    @Override
    public String toString() {
        return "Name{" + "name=" + this.nameString() + '}';
    }
    
}
